package com.aek.ebey.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aek.common.core.base.BaseProviderImpl;
import com.aek.ebey.sys.mapper.SysAreaMapper;
import com.aek.ebey.sys.model.SysArea;
import com.aek.ebey.sys.service.SysAreaService;

/**
 * <p>
 * 系统api表 服务实现类
 * </p>
 *
 * @author aek
 * @since 2017-05-06
 */
@Service
public class SysAreaServiceImpl extends BaseProviderImpl<SysArea> implements SysAreaService {

	private static final Integer PROVINCE = 0;
	private static final Integer TOWN = 1;
	private static final Integer REGION = 2;

	@Autowired
	private SysAreaMapper sysAreaMapper;

	public List<SysArea> queryByIdAndLevel(Long areaId, Integer level) {
		return sysAreaMapper.queryByIdAndLevel(areaId, level);
	}

	public List<SysArea> queryByParentIdAndLevel(Long parentId, Integer level) {
		return sysAreaMapper.queryByParentIdAndLevel(parentId, level);
	}

	public List<SysArea> queryByLevel(Integer level) {
		return sysAreaMapper.queryByLevel(level);
	}

	@Override
	public List<SysArea> queryProvince() {
		return this.queryByLevel(PROVINCE);
	}

	@Override
	public List<SysArea> queryTown(Long parentId) {
		return this.queryByParentIdAndLevel(parentId, TOWN);
	}

	@Override
	public List<SysArea> queryRegion(Long parentId) {
		return this.queryByParentIdAndLevel(parentId, REGION);
	}
}